/*
 * Copyright (c) 2010-2017 EEFUNG Software Co.Ltd. All rights reserved. 版权所有(c)2010-2017湖南蚁坊软件有限公司。保留所有权利。
 */
package com.spring.hystrix;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

/**
 * 功能描述,该部分必须以中文句号结尾。
 *
 * @author panqingcui
 * @create 2017-02-22 09:55
 */
@Service
public class CircuitBreakerService {
    @Autowired
    RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "addServiceFallback")
    public String addService() {
        return restTemplate.getForEntity("http://spring-cloud-service-server/add?a=10&b=20", String.class).getBody();
    }

    public String addServiceFallback() {
        return "error";
    }
}
